import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StrategyRuleVO, StrategyRuleForm, StrategyRuleQuery } from '@/api/device/strategyRule/types';

/**
 * 查询通行规则列表
 * @param query
 * @returns {*}
 */

export const listStrategyRule = (query?: StrategyRuleQuery): AxiosPromise<StrategyRuleVO[]> => {
  return request({
    url: '/device/strategyRule/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询通行规则详细
 * @param id
 */
export const getStrategyRule = (id: string | number): AxiosPromise<StrategyRuleVO> => {
  return request({
    url: '/device/strategyRule/' + id,
    method: 'get'
  });
};

/**
 * 新增通行规则
 * @param data
 */
export const addStrategyRule = (data: StrategyRuleForm) => {
  return request({
    url: '/device/strategyRule',
    method: 'post',
    data: data
  });
};

/**
 * 修改通行规则
 * @param data
 */
export const updateStrategyRule = (data: StrategyRuleForm) => {
  return request({
    url: '/device/strategyRule',
    method: 'put',
    data: data
  });
};

/**
 * 删除通行规则
 * @param id
 */
export const delStrategyRule = (id: string | number | Array<string | number>) => {
  return request({
    url: '/device/strategyRule/' + id,
    method: 'delete'
  });
};
